package com.dove.authority.mapper;

import com.dove.authority.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dove.authority.entity.vo.UserVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author run
 * @since 2021-03-18
 */
public interface UserMapper extends BaseMapper<User> {

    @Select("SELECT COUNT(*) FROM t_authority_user WHERE phone = #{phone]")
    public int findUserCountOfPhone(String phone);

    @Select("SELECT id, phone, name, sex, profile_photo FROM t_authority_user WHERE phone = #{phone}")
    public User findUserByPhone(String phone);

    @Select("SELECT user_id FROM t_authority_role_user WHERE role_id = #{roleId}")
    public List<Long> findUserOfRole(Long roleId);

}
